package cate.game.train.hero.msg;

import cate.common.annotation.OperationSetter;
import cate.common.table.d.GDOperation;
import cate.game.GameBody;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBTrain;
import cate.game.role.bag.hero.Hero;
import easy.java.dev.note.NoteField;
import easy.java.practice.errorcode.EcResult;

@ClientMsg(title = "英雄升级 の 请求")
@OperationSetter(GDOperation.HERO_LEVEL_UP)
public class HeroLevelUpReq implements MsgInput {
    @NoteField(value = "英雄的唯一ID")
    public String uid;

    @Override
    public void execute(GameBody game, ClientContext cc) {
        EcResult<Hero> r = game.train.hero.levelUp(cc.getRole(),uid);
        if(r.ok()){
            HeroBaseUpdateResp.send(cc.getRole(), r.data);
        }else{
            game.notice.message(cc.getRole(), r.message);
        }
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBTrain.HERO_LEVEL_UP_REQ;
    }
}
